using System;
using UnityEngine;

namespace Visuals
{
    public class BeatScaler : MonoBehaviour
    {
        [SerializeField] private float pulseScale = 1.15f;
        [SerializeField] private float recoverSpeed = 5f;


        private void OnEnable()
        {
            Beater.Beat += Pulse;
        }

        private void OnDisable()
        {
            Beater.Beat -= Pulse;
        }

        private void Update()
        {
            transform.localScale = Vector3.Lerp(
                transform.localScale, Vector3.one, 
                recoverSpeed * Time.deltaTime);
        }

        private void Pulse()
        {
            transform.localScale = pulseScale * Vector3.one;
        }
    }
}
